/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ModulodeVIFrame.java
 *
 * Created on 27/06/2012, 20:00:53
 */

package br.com.fatecpg.operon.frames;

import br.com.fatecpg.operon.Conexao;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 *
 * @author Fatec
 */
public class ModulodeCursoIFrame extends javax.swing.JInternalFrame {

    /** Creates new form ModulodeVIFrame */
    public ModulodeCursoIFrame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        SiglaLabel = new javax.swing.JLabel();
        TituloLabel = new javax.swing.JLabel();
        SiglaTextField = new javax.swing.JTextField();
        TituloTextField = new javax.swing.JTextField();
        PeriodoComboBox = new javax.swing.JComboBox();
        PeriodoLabel = new javax.swing.JLabel();
        PerfilProfissionalLabel = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        PerfilTextArea = new javax.swing.JTextArea();
        AdicionarButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        IDjLabel = new javax.swing.JLabel();
        IDTextField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();

        setClosable(true);
        setIconifiable(true);
        setResizable(true);
        setTitle("Módulo de Cursos");
        setPreferredSize(new java.awt.Dimension(570, 370));
        getContentPane().setLayout(null);

        SiglaLabel.setFont(new java.awt.Font("Arial", 1, 14));
        SiglaLabel.setText("Sigla:");
        getContentPane().add(SiglaLabel);
        SiglaLabel.setBounds(10, 150, 38, 17);

        TituloLabel.setFont(new java.awt.Font("Arial", 1, 14));
        TituloLabel.setText("Titulo:");
        getContentPane().add(TituloLabel);
        TituloLabel.setBounds(10, 110, 43, 17);
        getContentPane().add(SiglaTextField);
        SiglaTextField.setBounds(150, 150, 89, 20);
        getContentPane().add(TituloTextField);
        TituloTextField.setBounds(150, 110, 311, 20);

        PeriodoComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Manhã", "Tarde", "Noite" }));
        getContentPane().add(PeriodoComboBox);
        PeriodoComboBox.setBounds(150, 190, 90, 20);

        PeriodoLabel.setFont(new java.awt.Font("Arial", 1, 14));
        PeriodoLabel.setText("Periodo:");
        getContentPane().add(PeriodoLabel);
        PeriodoLabel.setBounds(10, 190, 59, 17);

        PerfilProfissionalLabel.setFont(new java.awt.Font("Arial", 1, 14));
        PerfilProfissionalLabel.setText("Perfil Profissional:");
        getContentPane().add(PerfilProfissionalLabel);
        PerfilProfissionalLabel.setBounds(10, 230, 128, 17);

        PerfilTextArea.setColumns(20);
        PerfilTextArea.setRows(5);
        jScrollPane1.setViewportView(PerfilTextArea);

        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(150, 230, 260, 119);

        AdicionarButton.setFont(new java.awt.Font("Arial", 1, 14));
        AdicionarButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/fatecpg/operon/icons/48px-Crystal_Clear_action_edit_add.png"))); // NOI18N
        AdicionarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AdicionarButtonActionPerformed(evt);
            }
        });
        getContentPane().add(AdicionarButton);
        AdicionarButton.setBounds(430, 300, 70, 50);

        jLabel1.setFont(new java.awt.Font("Arial", 1, 24));
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Módulo de Cursos");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(160, 10, 212, 29);
        getContentPane().add(jSeparator1);
        jSeparator1.setBounds(10, 51, 508, 10);

        IDjLabel.setFont(new java.awt.Font("Arial", 1, 14));
        IDjLabel.setText("ID:");
        getContentPane().add(IDjLabel);
        IDjLabel.setBounds(10, 70, 18, 17);
        getContentPane().add(IDTextField);
        IDTextField.setBounds(150, 70, 80, 20);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/fatecpg/operon/imagens/escola_1024x768.jpg"))); // NOI18N
        getContentPane().add(jLabel2);
        jLabel2.setBounds(0, -480, 570, 1060);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-567)/2, (screenSize.height-396)/2, 567, 396);
    }// </editor-fold>//GEN-END:initComponents

    private void AdicionarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AdicionarButtonActionPerformed
 
        String ID = IDTextField.getText();  
        String sigla = SiglaTextField.getText();   
        String titulo = TituloTextField.getText();       
        String periodo = PeriodoComboBox.getToolTipText();
        String perfil = PerfilTextArea.getText();      
        
        String SQL="INSERT INTO CURSO_ID VALUES" + "("+ID+")";
        String SQL1="INSERT INTO SIGLA VALUES" + "("+sigla+")";
        String SQL2="INSERT INTO TITULO VALUES" + "("+titulo+")";
        String SQL3="INSERT INTO PERIODOS VALUES" + "("+periodo+")";
        String SQL4="INSERT INTO PERFIL_PROFISSIONAL VALUES" + "("+perfil+")";
          
                  
        try{
            Conexao.con.createStatement().execute(SQL);
            this.dispose();
        
        }catch (SQLException ex){
            JOptionPane.showMessageDialog(this, "0 registro não pode ser inserido. Erro: "+ex.getMessage(),"Erro",JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_AdicionarButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AdicionarButton;
    private javax.swing.JTextField IDTextField;
    private javax.swing.JLabel IDjLabel;
    private javax.swing.JLabel PerfilProfissionalLabel;
    private javax.swing.JTextArea PerfilTextArea;
    private javax.swing.JComboBox PeriodoComboBox;
    private javax.swing.JLabel PeriodoLabel;
    private javax.swing.JLabel SiglaLabel;
    private javax.swing.JTextField SiglaTextField;
    private javax.swing.JLabel TituloLabel;
    private javax.swing.JTextField TituloTextField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    // End of variables declaration//GEN-END:variables

}
